<script>
    //生成餐券号码
    var zjsl_fieldid = WfForm.convertFieldNameToId("zjsl");//总计数量
    var cqkshm_fieldid = WfForm.convertFieldNameToId("cqkshm");//餐券号码开始
    var cqjshm_fieldid = WfForm.convertFieldNameToId("cqjshm");//餐券号码结束
    var sqsjvalue_fieldid = WfForm.convertFieldNameToId("sqsjvalue");//期限
    var sqsj_fieldid = WfForm.convertFieldNameToId("sqsj");//申请时间
    var zdqhm_fieldid = WfForm.convertFieldNameToId("zdqhm");//招待券号码
    var cqkshm = WfForm.getFieldValue(cqkshm_fieldid);
    var cqjshm = WfForm.getFieldValue(cqjshm_fieldid);
    var sqsjvalue = WfForm.getFieldValue(sqsjvalue_fieldid);
    var sqsj = WfForm.getFieldValue(sqsj_fieldid);
    var zjslvalue = WfForm.getFieldValue(zjsl_fieldid);
    var zdqhmvalue = WfForm.getFieldValue(zdqhm_fieldid);
    var str1 = sqsj.split("-");
    var curyear = str1[0];
    var curmonth = str1[1];
    var curday = str1[2];
    curday = curday.substring(2, 0);
    sqsjvalue = sqsjvalue.substring(sqsjvalue.indexOf("(") + 1, sqsjvalue.indexOf(")"));
    var str = sqsjvalue.split("-");
    var year1 = str[0];
    var month1 = str[1];
    var day1 = str[2];
    var year2 = str[3];
    var month2 = str[4];
    var day2 = str[5];
    var date1 = year1 + "-" + month1 + "-" + day1;
    var date2 = year2 + "-" + month2 + "-" + day2;
    var curdate = curyear + "-" + curmonth + "-" + curday;
    if(zdqhmvalue=='') zdqhmvalue= 0;
    if(cqkshm =="" && cqjshm ==""){
        if (date1 <= curdate && curdate < date2) {
            var counts = parseInt(zjslvalue) + parseInt(zdqhmvalue);
            zdqhmvalue = parseInt(zdqhmvalue)+parseInt(1);
            var cqkshm = (Array(3).join(0) +zdqhmvalue).slice(-3);

            var cqjshm = (Array(3).join(0) + counts).slice(-3);
            WfForm.changeFieldValue(cqkshm_fieldid, {value: cqkshm});
            WfForm.changeFieldValue(cqjshm_fieldid, {value: cqjshm});
        } else {
            var cqkshm = (Array(3).join(0) + 1).slice(-3);
            var cqjshm = (Array(3).join(0) + zjslvalue).slice(-3);
            WfForm.changeFieldValue(cqkshm_fieldid, {value: cqkshm});
            WfForm.changeFieldValue(cqjshm_fieldid, {value: cqjshm});
        }
    }


</script>



